package team18.yuejian.Model;

import android.provider.SyncStateContract;

import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import team18.yuejian.RetrofitListener;
import team18.yuejian.Server.MineService;
import team18.yuejian.bean.FocusBean;
import team18.yuejian.bean.NoteBean;
import team18.yuejian.bean.OrderBean;
import team18.yuejian.bean.PicBean;
import team18.yuejian.bean.UserBean;

public class MineModel extends RetrofitModel{
    private String url;
    private MineService service;
    private Retrofit retrofit;
    private RetrofitModel retrofitModel;

    public MineModel(){
        retrofitModel = new RetrofitModel();
        url = retrofitModel.getBaseUrl();
        retrofit = new Retrofit.Builder()
                .baseUrl(url)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        service = retrofit.create(MineService.class);
    }

    public void Mine(int id, final RetrofitListener listener){
        Call<UserBean> call = service.Mine(id);
        bindCallback(call,listener,null,0);

    }

    public void MineEdit(Map<String, RequestBody> bodyMap, MultipartBody.Part pic, final RetrofitListener listener){
        Call<UserBean> call =service.UserEdit(bodyMap,pic);
        bindCallback(call,listener,null,1);
    }

    public void MineGetOrderList (int uid, int otid, final RetrofitListener listener, int flag){
        Call<List<OrderBean>> call = service.orderList(uid,otid);
        bindCallback(call,listener,null,flag);
    }

    public void MineGetOrderDetail (int oid, int otid, final RetrofitListener listener){
        Call<OrderBean> call = service.orderDetail(oid,otid);
        bindCallback(call,listener,null,otid);
    }

    public void MineDeleteOrder (int oid, int uid, final RetrofitListener listener){
        Call<NoteBean> call = service.orderDelete(oid, uid);
        bindCallback(call,listener,null,5);
    }

    public void MineGetShowPic (int uid,final RetrofitListener listener){
        Call<List<PicBean>> call = service.getMinePic(uid);
        bindCallback(call,listener,null,6);
    }

    public void MineDeletePic (int uid, int spid, final RetrofitListener listener){
        Call<NoteBean> call = service.deletePic(uid,spid);
        bindCallback(call,listener,null,7);
    }

    public void MineFocus (int uid, final RetrofitListener listener){
        Call<List<FocusBean>> call = service.focusList(uid);
        bindCallback(call,listener,null,8);
    }

    public void MineDeleteFocus (int uid,int fid, final RetrofitListener listener){
        Call<NoteBean> call = service.deleteFocus(uid,fid);
        bindCallback(call,listener,null,9);
    }
}

